<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8"/>
    <meta name="keywords" content=""/>
    <meta name="description" content=""/>
    <title>小区管理</title>
    <link rel="stylesheet" href="../layui/css/layui.css">
    <link rel="stylesheet" href="../css/admin.css">
    <link rel="stylesheet" href="../css/lift.css">
    <link rel="stylesheet" href="../fonts/iconfont.css">
</head>
<style>
 .container{
 display: flex;
 background-color:#F3F3F3;
}
.detail{
  height:600px;
}
.layui-table[lay-skin=line] td, .layui-table[lay-skin=line] th{
/*   border-bottom: 0; */
  background-color:#fff;
}
  .layui-table td, .layui-table th{
    padding:14px 15px;
  }
  form{
    float:left;
    margin-top:10px;
    display: inline-block;
  }
  .layui-layer-btn,.layui-layer-content{
    text-align:center;
  }
</style>
<body>
  <div class="container">
<!--      <div class="org-floor">
        <ul id="navtree"> </ul>
  </div>-->
      <!-- 左边选项栏 -->
      <div class="org-floor">
          <button class="add-ad"  id="add-ads"  value="+&emsp;添加小区">添加小区</button>
          <button class="add-ad"  id="fix-district"  value="+&emsp;修改小区信息">修改小区信息</button>
          <button class="add-ad add-coin"  id="add-coin"  value="+&emsp;添加单元">添加单元</button>
          <ul id="navtree"> </ul>
      </div>
      <!-- 右边表格模块-->
    <div class="section-right">
     <div class="right-top">
     <div class="org-search"  name="myform">
     <input type="text" name="building_name" id="building_name"  value=""  placeholder="按小区搜索"  onfocus="this.style.color='#888';"  onblur="this.style.color='#777';"   style="font-size:12px;"/>
         <div id="search" style="cursor: pointer;"><i class="layui-icon" style="font-size: 25px; color: #EF7632;">&#xe615;</i> </div>
        </div>
<!--         <button class="layui-btn layui-btn-normal  left-1 "><span class="pic-3 iconfont icon-tianjiarenyuan"></span>导入单元</button> -->
 <!--        <button class="layui-btn layui-btn-normal  left-2"><span class="pic-3 iconfont icon-piliangdaoru"></span>添加电梯&emsp;/&emsp;摄像头</button>
-->
       <!-- <button class="layui-btn layui-btn-danger  a4 right"><span class="pic-4 iconfont icon-shanchu"></span>删除</button>-->
           </div>

<!--  table部分 -->
<div class="detail">
     <table class="layui-table" lay-skin="line" id="table">
      <thead >
         <tr>
          <!-- <th class="check"></th>-->
           <th>小区名称</th>
           <th>单&emsp;元</th>
           <th>设备id</th>
           <th>楼层数</th>
           <th>收费性质</th>
           <th>收费额度</th>
           <th>注册性质</th>
           <th>收费标准</th>
           <th>注册审核</th>
           <th>注册赠送次数</th>
           <th>状&emsp;态</th>
         </tr>
      </thead>
      <tbody class="org-table">
      </tbody>
      </table>
    <div id="page-fen">
        <div id="page-num"></div>
    </div>
  </div>
    </div>
  </div>
  <script src="../lib/jquery.js" type="text/javascript"></script>
  <script type="text/javascript" src="../layui/layui.js"></script>
<!--  <script type="text/javascript" src="../js/lift.js"></script>-->
  <script src="../lib/js/jquery.cookie.js" type="text/javascript"></script>
   <script>
      layui.use(['jquery','form','laypage','element','layer','tree'], function(){
        var element = layui.element;
        var $ = layui.jquery;
        var layer = layui.layer;
        var laypage = layui.laypage;

        var params={};
        var building_name=$("#building_name").val();
        var building_name="";

        var user_id =localStorage.getItem("user_id");
            console.log(user_id);

//查询小区的
        $("#search").off("click").on("click",function(){
          console.log(123);
            building_name = $.trim($("#building_name").val());
          searchTable();
        })
//回车搜索
    $("#building_name").on('keydown', function(e){  //
                if(e.keyCode == 13){
                    building_name = $.trim($("#building_name").val());
                   searchTable();
                }
            });
//回车搜索
          $("#add-ads").on("click",  function() {
              layer.open({
                  type:2
                  ,fix: false
                  ,shade:[0.1, '#fff'] //遮罩透明度
                  ,area:['300px', '380px']
                  ,title:['新增小区','font-weight:600;text-align:center;font-size:16px;border-radius:10px;']
                  ,content: 'add-village.html'
              });
          })
          //修改小区信息
          getFix();
          function getFix(building_id){
              if(building_id){
                  $.ajax({
                      url: "../../organization_manage/getBuildingInfo",
                      type: "GET",
                      data: {
                          building_id:building_id,
                      },
                      success: function(response){
                          var response = JSON.parse(response);
                          console.log(response);
                          params.price = response.building.price;
                          console.log(params.price);
                          params.reg_gift = response.building.reg_gift;
                          console.log(params.reg_gift);
                          params.reg_charge = response.building.reg_charge;
                          console.log(params.reg_charge);

                          var building_type = response.building.building_type;
                          console.log(building_type);
                          var chengti_type = response.building.chengti_type;
                          console.log(chengti_type);

/*
                          gettype(building_type);
                          getstyle(chengti_type);
*/

                          if(response.resultCode == '200'){

                          }
                      },
                      error:function(response){
                          console.log(response);
                          if(response.resultCode=='001'){
                              console.log("param is not found")
                          }
                      }
                  })
              }
/*              function gettype(building_type){
                  var opts_a = document.getElementById("tax_MS");
                  var value = String(building_type);
                  if(value!=""){
                      for(var i=0;i<opts_a.options.length;i++){
                          if(value == opts_a.options[i].value){
                              opts_a.options[i].selected = 'selected';
                              console.log(opts_a.options[i].value);
                              break;
                          }
                      }
                  }
              }
              function getstyle(chengti_type){
                  var opts_b = document.getElementById("tax_S");
                  var value = String(chengti_type);
                  if(value!=""){
                      for(var i=0;i<opts_b.options.length;i++){
                          if(value == opts_b.options[i].value){
                              opts_b.options[i].selected = 'selected';
                              console.log(opts_b.options[i].value);
                              break;
                          }
                      }
                  }
              }*/
          };
          fixDis();
          function fixDis(building_id){
           $("#fix-district").off("click").on("click",  function() {
                  if(building_id){
                      layer.open({
                          type:2
                          ,fix: false
                          ,shade:[0.1, '#fff']
                          ,area:['300px', '380px']
                          ,title:['小区信息修改','font-weight:600;text-align:center;font-size:16px;border-radius:10px;']
                          ,content: 'fix-districts.html',
                          success: function(layero, index){
                              var body = layer.getChildFrame('body', index);
                              body.contents().find("#tax_MY").val(params.price);
                              body.contents().find("#name_MM").val(params.reg_charge);
                              body.contents().find("#tax_free").val(params.reg_gift);
                          }
                      });
                  }else{
                      alert("请先选择小区");
                  }
              })
          };
          //添加单元
          addCoin();
          function addCoin(building_id){
              $("#add-coin").off("click").on("click",  function() {
                  if(building_id){
                      layer.open({
                          type:2
                          ,shade:[0.1, '#fff']
                          ,area:['360px', '250px']
                          ,title:['添加单元','font-weight:600;text-align:center;font-size:16px;border-radius:10px;']
                          ,content: 'add-unit.html',
                          success: function(layero, index){
                          }
                      });
                  }else{
                      alert("请先选择小区");
                  }
              })
          };

     var pages = {};
         searchTable();
      function searchTable(current_page){
        $.ajax({
          url: '../../building_manage/queryDanyuanByBuildingName',
          type: 'get',
          dataType: 'json',
          data:{
              building_name:building_name,
              wuye_id:user_id,
              current_page:current_page || 1,
              limit:10
          }
          })
         .done(function(response){
             console.log(response);
          if(response.resultCode == '200'){
              var str= '';
              var data = response.page.list;

          if(response.page.list.length){
            for(var i=0;i<response.page.list.length;i++){
                if(data[i].active == 0){
                    var active = "未激活";
                }else if(data[i].active == 1){
                    var active = "已激活";
                }else if(data[i].active == 1){
                    var active = "已注销";
                };
                if(data[i].is_check == 0){
                    var is_check = "不需要";
                }else if(data[i].is_check == 1){
                    var is_check = "需要 ";
                };
                if(data[i].is_check == 0){
                    var is_charge = "免费";
                }else if(data[i].is_check == 1){
                    var is_charge = "收费";
                };
                if(data[i].is_reg_charge == 0){
                    var is_reg_charge = "不收费";
                }else if(data[i].is_reg_charge == 1){
                    var is_reg_charge = "收费";
                };
            str +=
            '<tr>'+
            /*'<td class="check"><input data-id="'+ response.page.list[i].elevator_id +'" type="radio" name="lift_items" title="" lay-skin="primary"></td>'+*/
            '<td>'+ response.page.list[i].building_name +'</td>'+
            '<td>'+ response.page.list[i].zhuang_danyuan +'</td>'+
            '<td>'+ response.page.list[i].device_alias+'</td>'+
            '<td>'+ response.page.list[i].loucen+'</td>'+
            '<td>'+ is_charge+'</td>'+
            '<td>'+ response.page.list[i].reg_charge+'</td>'+
            '<td>'+ is_reg_charge+'</td>'+
            '<td>'+ response.page.list[i].reg_charge+'</td>'+
            '<td>'+ is_check+'</td>'+
            '<td>'+ response.page.list[i].reg_gift+'</td>'+
            '<td>'+ active+'</td>'+
            '</tr>'
          }
          $(".org-table").html(str);

            pages.total = response.page.total;
            console.log(pages.total);

            pages.current_page = response.page.current_page;
            console.log(pages.current_page);

            pages.totalPages = Math.ceil(pages.total/10);

         laypage({
            cont: 'page-num'
            ,pages: pages.totalPages
            // skip: true, 是否开启跳页
            ,curr: pages.current_page
            ,first: false
            ,last:false
            ,prev: '<em><</em>'
            ,next: '<em>></em>'
            ,jump: function(obj, first){
                   var curr = obj.curr;
                   console.log(curr);
            if(!first){
              searchTable(obj.curr);
                }
              }
          })
        }
        else{
          str = '<tr><td colspan="7">暂无数据</td></tr>';
          $(".org-table").html(str);
         }
        }
        })//done
           .fail(function(response){
              console.log("fail");
              if(response.resultCode=='001'){
                console.log("param is not found");
                }else if(response.resultCode=='009'){
                  console.log("String is not int type");
                }
            })
        };
//左侧导航栏部分
          dysou();
          function dysou(){
              $.ajax({
                  url:'../../organization_manage/getProvinceByWuyeId',
                  type: 'GET',
                  dataType: "json",
                  data:{
                      wuye_id: user_id
                  }
              })
                  .done(function(response){

                      if(response.resultCode==200){
                          var  data = response.provinces;

                          layui.tree({
                              elem: '#navtree',
                              skin: 'as',
                              drag: true,
                              click: function(id) {

                                  var attR =["province_id","city_id","district_id","building_id","danyuan_id","id"];
                                  var attr = [];
                                  for(var k in id) {
                                      attr.push(k);
                                  }
                                  for(var j=0;j<attR.length; j++){
                                      for(var m=0;m<attr.length;m++){
                                          if(attR[j] == attr[m]){

                                              var typeName = attr[m];
                                              localStorage.setItem("typeName",typeName);

                                              if(typeName == "province_id"){
                                                  var province_id = id.province_id;
                                                  params.province_id = province_id;
                                                  localStorage.setItem("provinceId",province_id);
                                                  console.log(province_id);
                                                  getByprovince();

                                              }else if(typeName == "city_id"){
                                                  var city_id = id.city_id;
                                                  params.city_id = city_id;
                                                  localStorage.setItem("cityId",city_id);
                                                  console.log(city_id);
                                                  getBycity();

                                              }else if(typeName == "district_id"){
                                                  var district_id = id.district_id;
                                                  params.district_id = district_id;
                                                  localStorage.setItem("districtId",district_id);
                                                  console.log(district_id);
                                                  getBydistrict();

                                              }else if(typeName == "building_id"){
                                                  var building_id = id.building_id;
                                                  params.building_id = building_id;
                                                  localStorage.setItem("buildingId",building_id);
                                                  console.log(building_id);
                                                  getBybuilding();
                                                  fixDis(building_id);
                                                  addCoin(building_id);
                                                  getFix(building_id);

                                              }else if(typeName == "id"){
                                                  var danyuan_id = id.id;
                                                  params.danyuan_id = danyuan_id;
                                                  localStorage.setItem("danyuanId",danyuan_id);
                                                  console.log(danyuan_id);
                                                  getBydanyuan();
                                              }
                                              //id赋值判断
                                          }//if
                                      }//for
                                  }//for
                                  $("body").on("mousedown",".layui-tree a cite",function(){
                                      $(".layui-tree a cite").css('color','#2C283C');
                                      $(this).css('color','#FABB42');
                                  });
                                  //依据省id查
                                  function getByprovince(currp){
                                      $.ajax({
                                          url: '../../building_manage/queryDanyuanByProvinceId',
                                          type: 'GET',
                                          dataType: 'json',
                                          data:{
                                              province_id:params.province_id,
                                              wuye_id:user_id,
                                              current_page:currp||1,
                                              limit:10
                                          }
                                      })
                                          .done(function (response) {
                                              console.log("province",response);

                                              if (response.resultCode == 200) {
                                                  var str = '';
                                                  var data = response.page.list;

                                                  if (response.page.list.length) {
                                                      for(var i=0;i<response.page.list.length;i++){
                                                          if(data[i].active == 0){
                                                              var active = "未激活";
                                                          }else if(data[i].active == 1){
                                                              var active = "已激活";
                                                          }else if(data[i].active == 1){
                                                              var active = "已注销";
                                                          };
                                                          if(data[i].is_check == 0){
                                                              var is_check = "不需要";
                                                          }else if(data[i].is_check == 1){
                                                              var is_check = "需要 ";
                                                          };
                                                          if(data[i].is_check == 0){
                                                              var is_charge = "免费";
                                                          }else if(data[i].is_check == 1){
                                                              var is_charge = "收费";
                                                          };
                                                          if(data[i].is_reg_charge == 0){
                                                              var is_reg_charge = "不收费";
                                                          }else if(data[i].is_reg_charge == 1){
                                                              var is_reg_charge = "收费";
                                                          };
                                                          str +=
                                                              '<tr>'+
                                                              /*'<td class="check"><input data-id="'+ response.page.list[i].elevator_id +'" type="radio" name="lift_items" title="" lay-skin="primary"></td>'+*/
                                                              '<td>'+ response.page.list[i].building_name +'</td>'+
                                                              '<td>'+ response.page.list[i].zhuang_danyuan +'</td>'+
                                                              '<td>'+ response.page.list[i].device_alias+'</td>'+
                                                              '<td>'+ response.page.list[i].loucen+'</td>'+
                                                              '<td>'+ is_charge+'</td>'+
                                                              '<td>'+ response.page.list[i].reg_charge+'</td>'+
                                                              '<td>'+ is_reg_charge+'</td>'+
                                                              '<td>'+ response.page.list[i].reg_charge+'</td>'+
                                                              '<td>'+ is_check+'</td>'+
                                                              '<td>'+ response.page.list[i].reg_gift+'</td>'+
                                                              '<td>'+ active+'</td>'+
                                                              '</tr>'
                                                      }
                                                      $(".org-table").html(str);
                                                      show();
                                                      pages.total = response.page.total;
                                                      console.log(pages.total);

                                                      pages.current_page = response.page.current_page;
                                                      console.log(pages.current_page);

                                                      pages.totalPages = Math.ceil(pages.total/10);
                                                      /*显示分页*/
                                                      laypage({
                                                          cont: 'page-num'
                                                          ,pages: pages.totalPages     //通过后台拿到的总页数
                                                          // skip: true, 是否开启跳页
                                                          ,curr: pages.current_page  //当前页
                                                          ,first: false
                                                          ,last:false
                                                          ,prev: '<em><</em>'
                                                          ,next: '<em>></em>'
                                                          ,jump: function(obj, first){ //触发分页后的回调
                                                              var currp = obj.curr;
                                                              console.log(currp);
                                                              localStorage.setItem("currp",currp);
                                                              if(!first){ //点击跳页触发函数自身，并传递当前页：obj.curr
                                                                  getByprovince(currp);
                                                              }
                                                          }
                                                      })
                                                  }
                                                  else {
                                                      str = '<tr><td colspan="7">暂无数据</td></tr>';
                                                      $(".org-table").html(str);
                                                      hidden();
                                                  }
                                              }//200
                                          })//done
                                          .fail(function(response){
                                              console.log("fail",response);
                                              if(resultCode='001'){
                                                  console.log("param is not found");
                                              }else if(resultCode='009'){
                                                  console.log("String is not int type");
                                              }
                                          });//fail
                                  }
                                  //依据市 id查询
                                  function getBycity(currc){
                                      $.ajax({
                                          url: '../../building_manage/queryDanyuanByCityId',
                                          type: 'GET',
                                          dataType: 'json',
                                          data:{
                                              city_id:params.city_id,
                                              wuye_id:user_id,
                                              current_page:currc || 1,
                                              limit:10
                                          }
                                      })
                                          .done(function(response) {
                                              console.log('success',response);
                                              if(response.resultCode == '200'){
                                                  var str= '';
                                                  var data = response.page.list;

                                                  if(response.page.list.length){
                                                      for(var i=0;i<response.page.list.length;i++){
                                                          if(data[i].active == 0){
                                                              var active = "未激活";
                                                          }else if(data[i].active == 1){
                                                              var active = "已激活";
                                                          }else if(data[i].active == 1){
                                                              var active = "已注销";
                                                          };
                                                          if(data[i].is_check == 0){
                                                              var is_check = "不需要";
                                                          }else if(data[i].is_check == 1){
                                                              var is_check = "需要 ";
                                                          };
                                                          if(data[i].is_check == 0){
                                                              var is_charge = "免费";
                                                          }else if(data[i].is_check == 1){
                                                              var is_charge = "收费";
                                                          };
                                                          if(data[i].is_reg_charge == 0){
                                                              var is_reg_charge = "不收费";
                                                          }else if(data[i].is_reg_charge == 1){
                                                              var is_reg_charge = "收费";
                                                          };
                                                          str +=
                                                              '<tr>'+
                                                              /*'<td class="check"><input data-id="'+ response.page.list[i].elevator_id +'" type="radio" name="lift_items" title="" lay-skin="primary"></td>'+*/
                                                              '<td>'+ response.page.list[i].building_name +'</td>'+
                                                              '<td>'+ response.page.list[i].zhuang_danyuan +'</td>'+
                                                              '<td>'+ response.page.list[i].device_alias+'</td>'+
                                                              '<td>'+ response.page.list[i].loucen+'</td>'+
                                                              '<td>'+ is_charge+'</td>'+
                                                              '<td>'+ response.page.list[i].reg_charge+'</td>'+
                                                              '<td>'+ is_reg_charge+'</td>'+
                                                              '<td>'+ response.page.list[i].reg_charge+'</td>'+
                                                              '<td>'+ is_check+'</td>'+
                                                              '<td>'+ response.page.list[i].reg_gift+'</td>'+
                                                              '<td>'+ active+'</td>'+
                                                              '</tr>'
                                                      }
                                                      $(".org-table").html(str);
//分页显示
                                                      show();
                                                      pages.total = response.page.total;
                                                      localStorage.setItem("total",response.page.total);

                                                      pages.current_page = response.page.current_page;
                                                      pages.totalPages = Math.ceil(pages.total/10);

                                                      laypage({
                                                          cont: 'page-num'
                                                          ,pages: pages.totalPages
                                                          ,curr: pages.current_page
                                                          ,first: 1
                                                          ,last:false
                                                          ,prev: '<em><</em>'
                                                          ,next: '<em>></em>'
                                                          ,jump: function(obj, first){
                                                              var currc = obj.curr;
                                                              console.log(currc);
                                                              localStorage.setItem("currc",currc);
                                                              if(!first){
                                                                  getBycity(currc);
                                                              }
                                                          }
                                                      })
                                                  }
                                                  else{
                                                      str = '<tr><td colspan="7">暂无数据</td></tr>';
                                                      $(".org-table").html(str);
                                                      hidden();
                                                  }//else
                                              }//200
                                          })//done
                                          .fail(function(response){
                                              console.log("fail",response);
                                              if(resultCode='001'){
                                                  console.log("param is not found");
                                              }else if(resultCode='009'){
                                                  console.log("String is not int type");
                                              }
                                          });//fail
                                  }
                                  //依据区 id查询

                                  function getBydistrict(currdi){
                                      $.ajax({
                                          url: '../../building_manage/queryDanyuanByDistrictId',
                                          type: 'GET',
                                          dataType: 'json',
                                          data:{
                                              district_id:params.district_id,
                                              wuye_id:user_id,
                                              current_page:currdi || 1,
                                              limit:10
                                          }
                                      })
                                          .done(function(response) {
                                              console.log("success",response);

                                              if(response.resultCode == '200'){
                                                  var str= '';
                                                   var data = response.page.list;

                                                  if(response.page.list.length){
                                                      for(var i=0;i<response.page.list.length;i++){
                                                          if(data[i].active == 0){
                                                              var active = "未激活";
                                                          }else if(data[i].active == 1){
                                                              var active = "已激活";
                                                          }else if(data[i].active == 1){
                                                              var active = "已注销";
                                                          };
                                                          if(data[i].is_check == 0){
                                                              var is_check = "不需要";
                                                          }else if(data[i].is_check == 1){
                                                              var is_check = "需要 ";
                                                          };
                                                          if(data[i].is_check == 0){
                                                              var is_charge = "免费";
                                                          }else if(data[i].is_check == 1){
                                                              var is_charge = "收费";
                                                          };
                                                          if(data[i].is_reg_charge == 0){
                                                              var is_reg_charge = "不收费";
                                                          }else if(data[i].is_reg_charge == 1){
                                                              var is_reg_charge = "收费";
                                                          };
                                                          str +=
                                                              '<tr>'+
                                                              /*'<td class="check"><input data-id="'+ response.page.list[i].elevator_id +'" type="radio" name="lift_items" title="" lay-skin="primary"></td>'+*/
                                                              '<td>'+ response.page.list[i].building_name +'</td>'+
                                                              '<td>'+ response.page.list[i].zhuang_danyuan +'</td>'+
                                                              '<td>'+ response.page.list[i].device_alias+'</td>'+
                                                              '<td>'+ response.page.list[i].loucen+'</td>'+
                                                              '<td>'+ is_charge+'</td>'+
                                                              '<td>'+ response.page.list[i].reg_charge+'</td>'+
                                                              '<td>'+ is_reg_charge+'</td>'+
                                                              '<td>'+ response.page.list[i].reg_charge+'</td>'+
                                                              '<td>'+ is_check+'</td>'+
                                                              '<td>'+ response.page.list[i].reg_gift+'</td>'+
                                                              '<td>'+ active+'</td>'+
                                                              '</tr>'
                                                      }
                                                      $(".org-table").html(str);
//分页显示
                                                      show();
                                                      pages.total = response.page.total;
                                                      localStorage.setItem("total",response.page.total);

                                                      pages.current_page = response.page.current_page;
                                                      pages.totalPages = Math.ceil(pages.total/10);

                                                      laypage({
                                                          cont: 'page-num'
                                                          ,pages: pages.totalPages
                                                          ,curr: pages.current_page
                                                          ,first: 1
                                                          ,last:false
                                                          ,prev: '<em><</em>'
                                                          ,next: '<em>></em>'
                                                          ,jump: function(obj, first){
                                                              var currdi = obj.curr;
                                                              console.log(currdi);
                                                              localStorage.setItem("currdi",currdi);
                                                              if(!first){
                                                                  getBydistrict(currdi);
                                                              }
                                                          }
                                                      })
                                                  }
                                                  else{
                                                      str = '<tr><td colspan="7">暂无数据</td></tr>';
                                                      $(".org-table").html(str);
                                                      hidden();

                                                  }//else
                                              }//200
                                          })//done
                                          .fail(function(response){
                                              console.log("fail",response);
                                              if(resultCode='001'){
                                                  console.log("param is not found");
                                              }else if(resultCode='009'){
                                                  console.log("String is not int type");
                                              }
                                          });//fail
                                  }
                                  //依据小区id查询

                                  function getBybuilding(currb){
                                      $.ajax({
                                          url: '../../building_manage/queryDanyuanByBuildingId',
                                          type: 'GET',
                                          dataType: 'json',
                                          data:{
                                              building_id:params.building_id,
                                              current_page:currb || 1,
                                              limit:10,
                                          }
                                      })
                                          .done(function(response) {
                                              console.log("success",response);

                                              if(response.resultCode == '200'){
                                                  var str= '';
                                                  var data = response.page.list;
                                                  if(response.page.list.length){
                                                      for(var i=0;i<response.page.list.length;i++){
                                                          if(data[i].active == 0){
                                                              var active = "未激活";
                                                          }else if(data[i].active == 1){
                                                              var active = "已激活";
                                                          }else if(data[i].active == 1){
                                                              var active = "已注销";
                                                          };
                                                          if(data[i].is_check == 0){
                                                              var is_check = "不需要";
                                                          }else if(data[i].is_check == 1){
                                                              var is_check = "需要 ";
                                                          };
                                                          if(data[i].is_check == 0){
                                                              var is_charge = "免费";
                                                          }else if(data[i].is_check == 1){
                                                              var is_charge = "收费";
                                                          };
                                                          if(data[i].is_reg_charge == 0){
                                                              var is_reg_charge = "不收费";
                                                          }else if(data[i].is_reg_charge == 1){
                                                              var is_reg_charge = "收费";
                                                          };
                                                          str +=
                                                              '<tr>'+
                                                              /*'<td class="check"><input data-id="'+ response.page.list[i].elevator_id +'" type="radio" name="lift_items" title="" lay-skin="primary"></td>'+*/
                                                              '<td>'+ response.page.list[i].building_name +'</td>'+
                                                              '<td>'+ response.page.list[i].zhuang_danyuan +'</td>'+
                                                              '<td>'+ response.page.list[i].device_alias+'</td>'+
                                                              '<td>'+ response.page.list[i].loucen+'</td>'+
                                                              '<td>'+ is_charge+'</td>'+
                                                              '<td>'+ response.page.list[i].reg_charge+'</td>'+
                                                              '<td>'+ is_reg_charge+'</td>'+
                                                              '<td>'+ response.page.list[i].reg_charge+'</td>'+
                                                              '<td>'+ is_check+'</td>'+
                                                              '<td>'+ response.page.list[i].reg_gift+'</td>'+
                                                              '<td>'+ active+'</td>'+
                                                              '</tr>'
                                                      }
                                                      $(".org-table").html(str);
                                                      show();
                                                      //分页显示
                                                      pages.total = response.page.total;
                                                      localStorage.setItem("total",response.page.total);

                                                      pages.current_page = response.page.current_page;
                                                      pages.totalPages = Math.ceil(pages.total/10);

                                                      laypage({
                                                          cont: 'page-num'
                                                          ,pages: pages.totalPages
                                                          ,curr: pages.current_page
                                                          ,first: 1
                                                          ,last:false
                                                          ,prev: '<em><</em>'
                                                          ,next: '<em>></em>'
                                                          ,jump: function(obj, first){ //触发分页后的回调
                                                              var currb = obj.curr;
                                                              console.log(currb);
                                                              localStorage.setItem("currb",currb);
                                                              if(!first){ //点击跳页触发函数自身，并传递当前页：obj.curr
                                                                  getBybuilding(currb);
                                                              }
                                                          }
                                                      });

                                                  }else{
                                                      str = '<tr><td colspan="7">暂无数据</td></tr>';
                                                      $(".org-table").html(str);
                                                      hidden();
                                                  }//else
                                              }//200
                                          })//done
                                          .fail(function(response){
                                              console.log("fail",response);
                                              if(resultCode='001'){
                                                  console.log("param is not found");
                                              }else if(resultCode='009'){
                                                  console.log("String is not int type");
                                              }
                                          });//fail
                                  }
                                  //依据单元i//查询
                                  function getBydanyuan(currd){
                                      $.ajax({
                                          url: '../../building_manage/queryDanyuanByDanyuanId',
                                          type: 'GET',
                                          dataType: 'json',
                                          data:{
                                              danyuan_id:params.danyuan_id,
                                              current_page:currd || 1,
                                              limit:10,
                                          }
                                      })
                                          .done(function(response) {
                                              console.log("success",response);

                                              if(response.resultCode == 200){
                                                  var str= '';
                                                  var data = response.page.list;

                                                  if(response.page.list.length){

                                                          for(var i=0;i<response.page.list.length;i++){
                                                              if(data[i].active == 0){
                                                                  var active = "未激活";
                                                              }else if(data[i].active == 1){
                                                                  var active = "已激活";
                                                              }else if(data[i].active == 1){
                                                                  var active = "已注销";
                                                              };
                                                              if(data[i].is_check == 0){
                                                                  var is_check = "不需要";
                                                              }else if(data[i].is_check == 1){
                                                                  var is_check = "需要 ";
                                                              };
                                                              if(data[i].is_check == 0){
                                                                  var is_charge = "免费";
                                                              }else if(data[i].is_check == 1){
                                                                  var is_charge = "收费";
                                                              };
                                                              if(data[i].is_reg_charge == 0){
                                                                  var is_reg_charge = "不收费";
                                                              }else if(data[i].is_reg_charge == 1){
                                                                  var is_reg_charge = "收费";
                                                              };
                                                              str +=
                                                                  '<tr>'+
                                                                  /*'<td class="check"><input data-id="'+ response.page.list[i].elevator_id +'" type="radio" name="lift_items" title="" lay-skin="primary"></td>'+*/
                                                                  '<td>'+ response.page.list[i].building_name +'</td>'+
                                                                  '<td>'+ response.page.list[i].zhuang_danyuan +'</td>'+
                                                                  '<td>'+ response.page.list[i].device_alias+'</td>'+
                                                                  '<td>'+ response.page.list[i].loucen+'</td>'+
                                                                  '<td>'+ is_charge+'</td>'+
                                                                  '<td>'+ response.page.list[i].reg_charge+'</td>'+
                                                                  '<td>'+ is_reg_charge+'</td>'+
                                                                  '<td>'+ response.page.list[i].reg_charge+'</td>'+
                                                                  '<td>'+ is_check+'</td>'+
                                                                  '<td>'+ response.page.list[i].reg_gift+'</td>'+
                                                                  '<td>'+ active+'</td>'+
                                                                  '</tr>'
                                                          }
                                                      $(".org-table").html(str);
                                                      //分页显示
                                                      show();
                                                      pages.total = response.page.total;
                                                      console.log(pages.total);

                                                      localStorage.setItem("total",response.page.total);

                                                      pages.current_page = response.page.current_page;

                                                      pages.totalPages = Math.ceil(pages.total/10);

                                                      laypage({
                                                          cont: 'page-num'
                                                          ,pages: pages.totalPages
                                                          ,curr: pages.current_page
                                                          ,first: 1
                                                          ,last:false
                                                          ,prev: '<em><</em>'
                                                          ,next: '<em>></em>'
                                                          ,jump: function(obj, first){ //触发分页后的回调
                                                              var currd = obj.curr;
                                                              localStorage.setItem("currd",currd);
                                                              if(!first){ //点击跳页触发函数自身，并传递当前页：obj.curr
                                                                  getBydanyuan(currd);
                                                              }
                                                          }
                                                      })
                                                  }
                                                  else{
                                                      str = '<tr><td colspan="7">暂无数据</td></tr>';
                                                      $(".org-table").html(str);
                                                      hidden();

                                                  }//else
                                              }//200
                                          })//done
                                          .fail(function(response){
                                              console.log("fail",response);
                                              if(resultCode='001'){
                                                  console.log("param is not found");
                                              }else if(resultCode='009'){
                                                  console.log("String is not int type");
                                              }
                                          });//fail
                                  }
                                  function show(){
                                      document.getElementById("page-fen").style.display="";
                                  };
                                  function hidden(){
                                      document.getElementById("page-fen").style.display="none";
                                  };
                              },//click
                              onchange: function (){
                                  console.log(this);
                              },
                              nodes: data
                          })//tree
                      }//200
                  })//done
                  .fail(function(response){
                      console.log("fail",response);
                  })
          }
    });
  </script>


</body>
</html>
